<?php
    $sql = "SELECT * FROM tintuc WHERE BiXoa=0";
    $result = DataProvider::ExecuteQuery($sql);

    $sql2 = "SELECT * FROM taikhoan";
    $result2 = DataProvider::ExecuteQuery($sql2);

    $sql3 = "SELECT * FROM sach";
    $result3 = DataProvider::ExecuteQuery($sql3);

    $baitren_mottrang = 4;
        if ( !$_GET['page'] )
        {
            $page = 0 ;
        }
        else
        {
            $page = $_GET['page'] ;
        }


        $sodu_lieu = mysql_num_rows($result3);
        $sotrang = $sodu_lieu/$baitren_mottrang;
        $startpage = $page*$baitren_mottrang;

        $sql4 = "SELECT * FROM sach ORDER BY MaSach DESC  LIMIT {$startpage},{$baitren_mottrang}";
        $result4 = DataProvider::ExecuteQuery($sql4);

?>


<div class="row-fluid">
    <div class="span4">
        <div class="head">
            <div class="isw-edit"></div>
            <h1>Tin Tức</h1>

            <ul class="buttons">
                <li>
                    <a href="#" class="isw-plus"  onclick="location = 'index.php?tintuc=3&id=<?php echo $row["MaTinTuc"] ?>';"></a>
                </li>
                <li>
                    <a href="#" class="isw-settings"></a>
                    <ul class="dd-list">
                        <li><a href="index.php?b=2"><span class="isw-list"></span> Chi Tiết</a></li>
                    </ul>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="block news scrollBox">

            <div class="scroll" style="height: 270px;">
                <?php
                    while($row = mysql_fetch_array($result))
                        {
                ?>

                <div class="item">
                    <a href="#"><?php echo $row['TieuDe']; ?></a>
                    <p><?php echo $row['NoiDung']; ?></p><br>

                    <div class="controls">
                        <a href="#" class="icon-pencil" onclick="location = 'index.php?tintuc=1&id=<?php echo $row["MaTinTuc"] ?>';"></a>
                        <a href="#" class="icon-trash" onclick="location = 'index.php?tintuc=2&id=<?php echo $row["MaTinTuc"] ?>';"></a>
                    </div>
                </div>

                <?php
                    }
                ?>

            </div>

        </div>
    </div>
    <div class="span4">
        <div class="head">
            <div class="isw-user"></div>
            <h1>Người Dùng</h1>

            <ul class="buttons">
                <li>
                    <a href="#" class="isw-plus"  onclick="location = 'index.php?user=3&id=<?php echo $row2["MaTaiKhoan"] ?>';"></a>
                </li>
                <li>
                    <a href="#" class="isw-settings"></a>
                    <ul class="dd-list">
                        <li><a href="index.php?b=3"><span class="isw-list"></span> Chi Tiết</a></li>
                    </ul>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="block news scrollBox">

            <div class="scroll" style="height: 270px;">
                <?php
                    while($row2 = mysql_fetch_array($result2))
                        {
                ?>


                <div class="item">
                    <a href="#">Tên Đăng Nhập: <?php echo $row2['TenDangNhap']; ?></a><br>
                    <span><?php echo $row2['HoVaTen']; ?></span>

                    <div class="controls">
                        <a href="#" class="icon-pencil" onclick="location = 'index.php?user=1&id=<?php echo $row2["MaTaiKhoan"] ?>';"></a>
                        <a href="#" class="icon-trash" onclick="location = 'index.php?user=2&id=<?php echo $row2["MaTaiKhoan"] ?>';"></a>
                    </div>
                </div>

                <?php
                    }
                ?>

            </div>

        </div>
    </div>
    <div class="span4">
        <div class="head">
            <div class="isw-archive"></div>
            <h1>Đơn đặt hàng</h1>
            <ul class="buttons">
                <li>
                    <a href="#" class="isw-settings"></a>
                    <ul class="dd-list">
                        <li><a href="#"><span class="isw-list"></span> Show all</a></li>
                        <li><a href="#"><span class="isw-ok"></span> Approved</a></li>
                        <li><a href="#"><span class="isw-minus"></span> Unapproved</a></li>
                        <li><a href="#"><span class="isw-refresh"></span> Refresh</a></li>
                    </ul>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="block-fluid accordion">

            <h3>November 2012</h3>
            <div>
                <table cellpadding="0" cellspacing="0" width="100%" class="sOrders">
                    <thead>
                        <tr>
                            <th width="60">Date</th><th>User</th><th width="60">Price</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><span class="date">Nov 6</span><span class="time">12:35</span></td>
                            <td><a href="#">Aqvatarius</a></td>
                            <td><span class="price">$1366.12</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Nov 8</span><span class="time">18:42</span></td>
                            <td><a href="#">Olga</a></td>
                            <td><span class="price">$146.00</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Nov 15</span><span class="time">8:21</span></td>
                            <td><a href="#">Alex</a></td>
                            <td><span class="price">$879.24</span></td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="3" align="right"><button class="btn btn-small">More...</button></td>
                        </tr>
                    </tfoot>
                </table>
            </div>

            <h3>October 2012</h3>
            <div>
                <table cellpadding="0" cellspacing="0" width="100%" class="sOrders">
                    <thead>
                        <tr>
                            <th width="60">Date</th><th>User</th><th width="60">Price</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><span class="date">Oct 6</span><span class="time">12:35</span></td>
                            <td><a href="#">Aqvatarius</a></td>
                            <td><span class="price">$1366.12</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Oct 8</span><span class="time">18:42</span></td>
                            <td><a href="#">Olga</a></td>
                            <td><span class="price">$146.00</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Oct 15</span><span class="time">8:21</span></td>
                            <td><a href="#">Alex</a></td>
                            <td><span class="price">$879.24</span></td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="3" align="right"><button class="btn btn-small">More...</button></td>
                        </tr>
                    </tfoot>
                </table>
            </div>

            <h3>September 2012</h3>
            <div>
                <table cellpadding="0" cellspacing="0" width="100%" class="sOrders">
                    <thead>
                        <tr>
                            <th width="60">Date</th><th>User</th><th width="60">Price</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><span class="date">Sep 6</span><span class="time">12:35</span></td>
                            <td><a href="#">Aqvatarius</a></td>
                            <td><span class="price">$1366.12</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Sep 8</span><span class="time">18:42</span></td>
                            <td><a href="#">Olga</a></td>
                            <td><span class="price">$146.00</span></td>
                        </tr>
                        <tr>
                            <td><span class="date">Sep 15</span><span class="time">8:21</span></td>
                            <td><a href="#">Alex</a></td>
                            <td><span class="price">$879.24</span></td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="3" align="right"><button class="btn btn-small">More...</button></td>
                        </tr>
                    </tfoot>
                </table>
            </div>

        </div>
    </div>

</div>

<div class="dr"><span></span></div>

<div class="row-fluid">

    <div class="span12">
        <div class="head">
            <div class="isw-picture"></div>
            <h1>Sách</h1>
            <ul class="buttons">
                <li>
                    <a href="#" class="isw-plus"  onclick="location = 'index.php?sach=3&id=<?php echo $row4["MaSach"] ?>';"></a>
                </li>
                <li>
                    <a href="#" class="isw-settings"></a>
                    <ul class="dd-list">
                        <li><a href="index.php?b=4"><span class="isw-list"></span> Chi Tiết</a></li>
                    </ul>
                </li>
            </ul>
            <div class="clear"></div>

        </div>

        <table>
            <div class="block thumbs">
                <?php
                    while($row4 = mysql_fetch_array($result4))
                        {
                ?>


                <div class="thumbnail">
                    <a class="fancybox" rel="group" href="../<?php echo $row4['HinhURL']; ?>"><img src="../<?php echo $row4['HinhURL']; ?>" class="img-polaroid"/></a>
                    <div class="caption">
                        <h5 class="text-info"><?php echo $row4['TenSach']; ?></h5>
                        <span>

                        </span>
                        <p>Tác giả: <?php echo $row4['TacGia']; ?></p>
                        <br>
                        <p>Số Lượng Tồn: <?php echo $row4['SoLuongTon']; ?></p>
                        <p>Số Lượng Cho Mượn: <?php echo $row4['SoLuongChoMuon']; ?></p>
                        <p>Số Lượt Xem: <?php echo $row4['SoLuotXem']; ?></p>
                        <br>
                        <p>Ngày Đăng: <?php echo $row4['NgayDangSach']; ?></p>


                        <p>
                            <a class="btn btn-info" onclick="location = 'index.php?sach=4&id=<?php echo $row4["MaSach"] ?>';">Chi Tiết</a>
                            <a class="btn btn-danger" onclick="location = 'index.php?sach=2&id=<?php echo $row4["MaSach"]?>';">Xóa</a>
                        </p>
                    </div>
                </div>
                <?php
                    }
                    echo "Trang: ";
                    for ( $page = 1; $page <= $sotrang; $page ++ )
                        {
                            echo "<a href='index.php?b=1&page={$page}'>{$page}</a>"."&nbsp&nbsp&nbsp";
                        }
                ?>

                <div class="clear"></div>
            </div>
        </table>
    </div>

</div>

<div class="dr"><span></span></div>

</div>